home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / crbaloon.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  13KB  |  440 lines

  1. /***************************************************************************
  2.  
  3. Crazy Balloon memory map (preliminary)
  4.  
  5. 0000-2fff ROM
  6. 4000-43ff RAM
  7. 4800-4bff Video RAM
  8. 5000-53ff Color RAM
  9.  
  10. I/O:
  11.  
  12. read:
  13. 00        dsw
  14. 01        joystick
  15. 02        bit 0-3 from chip PC3259 (bit 3 is the sprite/char collision detection)
  16.           bit 4-7 dsw
  17. 03        bit 0 dsw
  18.           bit 1 high score name reset
  19.           bit 2 service
  20.           bit 3 tilt
  21.           bit 4-7 from chip PC3092; coin inputs & start buttons
  22. 06-0a-0e  mirror addresses for 02; address lines 2 and 3 go to the PC3256 chip
  23.           so they probably alter its output, while the dsw bits (4-7) stay the same.
  24.  
  25. write:
  26. 01        ?
  27. 02        bit 0-3 sprite code bit 4-7 sprite color
  28. 03        sprite X pos
  29. 04        sprite Y pos
  30. 05        music?? to a counter?
  31. 06        sound
  32.           bit 0 IRQ enable/acknowledge
  33.           bit 1 sound enable
  34.           bit 2 sound related (to amplifier)
  35.           bit 3 explosion (to 76477)
  36.           bit 4 breath (to 76477)
  37.           bit 5 appear (to 76477)
  38.           bit 6 sound related (to 555)
  39.           bit 7 to chip PC3259
  40. 07        to chip PC3092 (bits 0-3)
  41. 08        to chip PC3092 (bits 0-3)
  42.           bit 0 seems to be flip screen
  43.           bit 1 might enable coin input
  44. 09        to chip PC3092 (bits 0-3)
  45. 0a        to chip PC3092 (bits 0-3)
  46. 0b        to chip PC3092 (bits 0-3)
  47. 0c        MSK (to chip PC3259)
  48. 0d        CC (not used)
  49.  
  50. ***************************************************************************/
  51.  
  52. #include "driver.h"
  53. #include "vidhrdw/generic.h"
  54.  
  55.  
  56. WRITE_HANDLER( crbaloon_spritectrl_w );
  57. WRITE_HANDLER( crbaloon_flipscreen_w );
  58. void crbaloon_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  59. void crbaloon_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  60.  
  61.  
  62. int val06,val08,val0a;
  63.  
  64. static void crbaloon_machine_init(void)
  65. {
  66.     /* MIXER A = 0, MIXER C = 1 */
  67.     SN76477_mixer_a_w(0, 0);
  68.     SN76477_mixer_c_w(0, 1);
  69.     /* ENVELOPE is constant: pin1 = hi, pin 28 = lo */
  70.     SN76477_envelope_w(0, 1);
  71.     /* fake: pulse the enable line to get rid of the constant noise */
  72.     SN76477_enable_w(0, 1);
  73.     SN76477_enable_w(0, 0);
  74. }
  75.  
  76. WRITE_HANDLER( crbaloon_06_w )
  77. {
  78.     val06 = data;
  79.  
  80.     interrupt_enable_w(offset,data & 1);
  81.  
  82.     /* SOUND STOP high? */
  83.     if( data & 0x02 )
  84.     {
  85.  
  86.         if( data & 0x08 )
  87.         {
  88.             /* enable is connected to EXPLOSION */
  89.             SN76477_enable_w(0, 1);
  90.         }
  91.         else
  92.         {
  93.             SN76477_enable_w(0, 0);
  94.         }
  95.         if( data & 0x10 )
  96.         {
  97.             /* BREATH changes slf_res to 10k (middle of two 10k resistors) */
  98.             SN76477_set_slf_res(0, RES_K(10));
  99.             /* it also puts a tantal capacitor agains GND on the output,
  100.                but this section of the schematics is not readable. */
  101.         }
  102.         else
  103.         {
  104.             SN76477_set_slf_res(0, RES_K(20));
  105.         }
  106.  
  107.         if( data & 0x20 )
  108.         {
  109.             /* APPEAR is connected to MIXER B */
  110.             SN76477_mixer_b_w(0, 1);
  111.         }
  112.         else
  113.         {
  114.             SN76477_mixer_b_w(0, 4);
  115.         }
  116.  
  117.         /* constant: pin1 = hi, pin 28 = lo */
  118.         SN76477_envelope_w(0, 1);
  119.     }
  120. }
  121.  
  122. WRITE_HANDLER( crbaloon_08_w )
  123. {
  124.     val08 = data;
  125.  
  126.     crbaloon_flipscreen_w(offset,data & 1);
  127. }
  128.  
  129. WRITE_HANDLER( crbaloon_0a_w )
  130. {
  131.     val0a = data;
  132. }
  133.  
  134. READ_HANDLER( crbaloon_IN2_r )
  135. {
  136.     extern int crbaloon_collision;
  137.  
  138.     if (crbaloon_collision != 0)
  139.     {
  140.         return (input_port_2_r(0) & 0xf0) | 0x08;
  141.     }
  142.  
  143.     /* the following is needed for the game to boot up */
  144.     if (val06 & 0x80)
  145.     {
  146. logerror("PC %04x: %02x high\n",cpu_get_pc(),offset);
  147.         return (input_port_2_r(0) & 0xf0) | 0x07;
  148.     }
  149.     else
  150.     {
  151. logerror("PC %04x: %02x low\n",cpu_get_pc(),offset);
  152.         return (input_port_2_r(0) & 0xf0) | 0x07;
  153.     }
  154. }
  155.  
  156. READ_HANDLER( crbaloon_IN3_r )
  157. {
  158.     if (val08 & 0x02)
  159.         /* enable coin & start input? Wild guess!!! */
  160.         return input_port_3_r(0);
  161.  
  162.     /* the following is needed for the game to boot up */
  163.     if (val0a & 0x01)
  164.     {
  165. logerror("PC %04x: 03 high\n",cpu_get_pc());
  166.         return (input_port_3_r(0) & 0x0f) | 0x00;
  167.     }
  168.     else
  169.     {
  170. logerror("PC %04x: 03 low\n",cpu_get_pc());
  171.         return (input_port_3_r(0) & 0x0f) | 0x00;
  172.     }
  173. }
  174.  
  175.  
  176. READ_HANDLER( crbaloon_IN_r )
  177. {
  178.     switch (offset & 0x03)
  179.     {
  180.         case 0:
  181.             return input_port_0_r(offset);
  182.  
  183.         case 1:
  184.             return input_port_1_r(offset);
  185.  
  186.         case 2:
  187.             return crbaloon_IN2_r(offset);
  188.  
  189.         case 3:
  190.             return crbaloon_IN3_r(offset);
  191.     }
  192.  
  193.     return 0;
  194. }
  195.  
  196.  
  197.  
  198. static struct MemoryReadAddress readmem[] =
  199. {
  200.     { 0x0000, 0x2fff, MRA_ROM },
  201.     { 0x4000, 0x43ff, MRA_RAM },
  202.     { 0x4800, 0x4bff, MRA_RAM },
  203.     { 0x5000, 0x53ff, MRA_RAM },
  204.     { -1 }    /* end of table */
  205. };
  206.  
  207. static struct MemoryWriteAddress writemem[] =
  208. {
  209.     { 0x0000, 0x2fff, MWA_ROM },
  210.     { 0x4000, 0x43ff, MWA_RAM },
  211.     { 0x4800, 0x4bff, videoram_w, &videoram, &videoram_size },
  212.     { 0x5000, 0x53ff, colorram_w, &colorram },
  213.     { -1 }    /* end of table */
  214. };
  215.  
  216. static struct IOReadPort readport[] =
  217. {
  218.     { 0x00, 0x0f, crbaloon_IN_r },
  219.     { -1 }    /* end of table */
  220. };
  221.  
  222. static struct IOWritePort writeport[] =
  223. {
  224.     { 0x02, 0x04, crbaloon_spritectrl_w },
  225.     { 0x06, 0x06, crbaloon_06_w },
  226.     { 0x08, 0x08, crbaloon_08_w },
  227.     { 0x0a, 0x0a, crbaloon_0a_w },
  228.     { -1 }    /* end of table */
  229. };
  230.  
  231.  
  232.  
  233. INPUT_PORTS_START( crbaloon )
  234.     PORT_START
  235.     PORT_DIPNAME( 0x01, 0x01, "Test?" )
  236.     PORT_DIPSETTING(    0x01, "I/O Check?" )
  237.     PORT_DIPSETTING(    0x00, "RAM Check?" )
  238.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Cabinet ) )
  239.     PORT_DIPSETTING(    0x02, DEF_STR( Upright ) )
  240.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  241.     PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Lives ) )
  242.     PORT_DIPSETTING(    0x00, "2" )
  243.     PORT_DIPSETTING(    0x04, "3" )
  244.     PORT_DIPSETTING(    0x08, "4" )
  245.     PORT_DIPSETTING(    0x0c, "5" )
  246.     PORT_DIPNAME( 0x10, 0x00, DEF_STR( Bonus_Life ) )
  247.     PORT_DIPSETTING(    0x00, "5000" )
  248.     PORT_DIPSETTING(    0x10, "10000" )
  249.     PORT_DIPNAME( 0xe0, 0x80, DEF_STR( Coinage ) )
  250.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  251.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_1C ) )
  252.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_1C ) )
  253.     PORT_DIPSETTING(    0x80, DEF_STR( 1C_1C ) )
  254.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_2C ) )
  255.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_3C ) )
  256.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_4C ) )
  257.     PORT_DIPSETTING(    0x00, "Disable" )
  258.  
  259.     PORT_START
  260.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  261.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  262.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  263.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  264.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
  265.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
  266.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
  267.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
  268.  
  269.     PORT_START
  270.     PORT_BIT( 0x0f, IP_ACTIVE_HIGH, IPT_UNKNOWN )    /* from chip PC3259 */
  271.     PORT_BITX(    0x10, 0x10, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE )
  272.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  273.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  274.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  275.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  276.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  277.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
  278.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  279.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  280.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
  281.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  282.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  283.  
  284.     PORT_START
  285.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
  286.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  287.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  288.     PORT_BITX(0x02, IP_ACTIVE_LOW, IPT_BUTTON1, "High Score Name Reset", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
  289.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )    /* should be COIN2 */
  290.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_TILT )
  291.     /* the following four bits come from chip PC3092 */
  292.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
  293.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
  294.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN1 )
  295.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  296. INPUT_PORTS_END
  297.  
  298.  
  299.  
  300. static struct GfxLayout charlayout =
  301. {
  302.     8,8,    /* 8*8 characters */
  303.     256,    /* 256 characters */
  304.     1,    /* 1 bit per pixel */
  305.     { 0 },
  306.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  307.     { 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 },
  308.     8*8    /* every char takes 8 consecutive bytes */
  309. };
  310. static struct GfxLayout spritelayout =
  311. {
  312.     32,32,    /* 32*32 sprites */
  313.     16,    /* 16 sprites */
  314.     1,    /* 1 bit per pixel */
  315.     { 0 },
  316.     { 3*32*8+0, 3*32*8+1, 3*32*8+2, 3*32*8+3, 3*32*8+4, 3*32*8+5, 3*32*8+6, 3*32*8+7,
  317.             2*32*8+0, 2*32*8+1, 2*32*8+2, 2*32*8+3, 2*32*8+4, 2*32*8+5, 2*32*8+6, 2*32*8+7,
  318.             1*32*8+0, 1*32*8+1, 1*32*8+2, 1*32*8+3, 1*32*8+4, 1*32*8+5, 1*32*8+6, 1*32*8+7,
  319.             0*32*8+0, 0*32*8+1, 0*32*8+2, 0*32*8+3, 0*32*8+4, 0*32*8+5, 0*32*8+6, 0*32*8+7 },
  320.     { 31*8, 30*8, 29*8, 28*8, 27*8, 26*8, 25*8, 24*8,
  321.             23*8, 22*8, 21*8, 20*8, 19*8, 18*8, 17*8, 16*8,
  322.             15*8, 14*8, 13*8, 12*8, 11*8, 10*8, 9*8, 8*8,
  323.             7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 },
  324.     32*4*8  /* every sprite takes 128 consecutive bytes */
  325. };
  326.  
  327.  
  328. static struct GfxDecodeInfo gfxdecodeinfo[] =
  329. {
  330.     { REGION_GFX1, 0, &charlayout,   0, 16 },
  331.     { REGION_GFX2, 0, &spritelayout, 0, 16 },
  332.     { -1 } /* end of array */
  333. };
  334.  
  335.  
  336. static struct SN76477interface sn76477_interface =
  337. {
  338.     1,    /* 1 chip */
  339.     { 100 }, /* mixing level   pin description         */
  340.     { RES_K( 47)   },        /*    4  noise_res         */
  341.     { RES_K(330)   },        /*    5  filter_res         */
  342.     { CAP_P(470)   },        /*    6  filter_cap         */
  343.     { RES_K(220)   },        /*    7  decay_res         */
  344.     { CAP_U(1.0)   },        /*    8  attack_decay_cap  */
  345.     { RES_K(4.7)   },        /* 10  attack_res         */
  346.     { RES_M(  1)   },        /* 11  amplitude_res     */
  347.     { RES_K(200)   },        /* 12  feedback_res      */
  348.     { 5.0           },        /* 16  vco_voltage         */
  349.     { CAP_P(470)   },        /* 17  vco_cap             */
  350.     { RES_K(330)   },        /* 18  vco_res             */
  351.     { 5.0           },        /* 19  pitch_voltage     */
  352.     { RES_K( 20)   },        /* 20  slf_res             */
  353.     { CAP_P(420)   },        /* 21  slf_cap             */
  354.     { CAP_U(1.0)   },        /* 23  oneshot_cap         */
  355.     { RES_K( 47)   }        /* 24  oneshot_res         */
  356. };
  357.  
  358.  
  359. static struct MachineDriver machine_driver_crbaloon =
  360. {
  361.     /* basic machine hardware */
  362.     {
  363.         {
  364.             CPU_Z80,
  365.             3072000,    /* 3.072 Mhz ????? */
  366.             readmem,writemem,readport,writeport,
  367.             interrupt,1
  368.         }
  369.     },
  370.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  371.     1,    /* single CPU, no need for interleaving */
  372.     crbaloon_machine_init,
  373.  
  374.     /* video hardware */
  375.     32*8, 32*8, { 0*8, 32*8-1, 4*8, 32*8-1 },
  376.     gfxdecodeinfo,
  377.     16, 16*2,
  378.     crbaloon_vh_convert_color_prom,
  379.  
  380.     VIDEO_TYPE_RASTER|VIDEO_SUPPORTS_DIRTY,
  381.     0,
  382.     generic_vh_start,
  383.     generic_vh_stop,
  384.     crbaloon_vh_screenrefresh,
  385.  
  386.     /* sound hardware */
  387.     0,0,0,0,
  388.     {
  389.         {
  390.             SOUND_SN76477,
  391.             &sn76477_interface
  392.         }
  393.     }
  394. };
  395.  
  396.  
  397.  
  398. /***************************************************************************
  399.  
  400.   Game driver(s)
  401.  
  402. ***************************************************************************/
  403.  
  404. ROM_START( crbaloon )
  405.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for code */
  406.     ROM_LOAD( "cl01.bin",     0x0000, 0x0800, 0x9d4eef0b )
  407.     ROM_LOAD( "cl02.bin",     0x0800, 0x0800, 0x10f7a6f7 )
  408.     ROM_LOAD( "cl03.bin",     0x1000, 0x0800, 0x44ed6030 )
  409.     ROM_LOAD( "cl04.bin",     0x1800, 0x0800, 0x62f66f6c )
  410.     ROM_LOAD( "cl05.bin",     0x2000, 0x0800, 0xc8f1e2be )
  411.     ROM_LOAD( "cl06.bin",     0x2800, 0x0800, 0x7d465691 )
  412.  
  413.     ROM_REGION( 0x0800, REGION_GFX1 | REGIONFLAG_DISPOSE )
  414.     ROM_LOAD( "cl07.bin",     0x0000, 0x0800, 0x2c1fbea8 )
  415.  
  416.     ROM_REGION( 0x0800, REGION_GFX2 | REGIONFLAG_DISPOSE )
  417.     ROM_LOAD( "cl08.bin",     0x0000, 0x0800, 0xba898659 )
  418. ROM_END
  419.  
  420. ROM_START( crbalon2 )
  421.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for code */
  422.     ROM_LOAD( "cl01.bin",     0x0000, 0x0800, 0x9d4eef0b )
  423.     ROM_LOAD( "crazybal.ep2", 0x0800, 0x0800, 0x87572086 )
  424.     ROM_LOAD( "crazybal.ep3", 0x1000, 0x0800, 0x575fe995 )
  425.     ROM_LOAD( "cl04.bin",     0x1800, 0x0800, 0x62f66f6c )
  426.     ROM_LOAD( "cl05.bin",     0x2000, 0x0800, 0xc8f1e2be )
  427.     ROM_LOAD( "crazybal.ep6", 0x2800, 0x0800, 0xfed6ff5c )
  428.  
  429.     ROM_REGION( 0x0800, REGION_GFX1 | REGIONFLAG_DISPOSE )
  430.     ROM_LOAD( "cl07.bin",     0x0000, 0x0800, 0x2c1fbea8 )
  431.  
  432.     ROM_REGION( 0x0800, REGION_GFX2 | REGIONFLAG_DISPOSE )
  433.     ROM_LOAD( "cl08.bin",     0x0000, 0x0800, 0xba898659 )
  434. ROM_END
  435.  
  436.  
  437.  
  438. GAMEX( 1980, crbaloon, 0,        crbaloon, crbaloon, 0, ROT90, "Taito Corporation", "Crazy Balloon (set 1)", GAME_IMPERFECT_SOUND )
  439. GAMEX( 1980, crbalon2, crbaloon, crbaloon, crbaloon, 0, ROT90, "Taito Corporation", "Crazy Balloon (set 2)", GAME_IMPERFECT_SOUND )
  440.